const app = getApp();
const school_list = require('../../../_self/school.js').school_list;

Page({
  data: {
    StatusBar: app.globalData.StatusBar,
    CustomBar: app.globalData.CustomBar,
    hidden: true,
    searchkey:''
  },
  getsearchkey(e){
    this.setData({
      searchkey:e.detail.value
    })
  },
  onLoad() {
    let list = [];

    this.setData({
      list: school_list,
      listCur: school_list[0]
    })
  },
  onReady() {
   
  },
  //选择学校
  sels(e){
    const allpages = getCurrentPages();
    const prepage = allpages[allpages.length - 2];
    var sid = e.currentTarget.dataset.id;
    //console.log(allpages)
    app.sel_item = school_list[sid]
    prepage.setData({
      sel:school_list[sid]
    },()=>{wx.navigateBack()})

  },
  //获取文字信息
  search(){
    //console.log('开始匹配')
    var _ = this;
    //正则匹配
    var reg = new RegExp(_.data.searchkey);
    let sl = school_list;
    let _sl = [];
    for(var i=0;i<sl.length;i++){
      if(sl[i].name.match(reg)){
        _sl.push(sl[i]);
      }
    }
    //console.log(_sl)
    _.setData({
      list:_sl
    })
  }

});